package com.zhangyj.impl.component.type;

public class HyperLink {
	private String url = "";
	private String value = "";
	private String caption = "";
	private String target = "_self";

	public HyperLink(String url, String value, String caption, String target) {
		this.setCaption(caption);
		this.setTarget(target);
		this.setUrl(url);
		this.setValue(value);
	}

	public HyperLink() {
		this.setCaption(null);
		this.setTarget(null);
		this.setUrl(null);
		this.setValue(null);
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public String toString() {
		if (this.url == null) {
			return "--";
		}
		String url = this.url;
		if (!url.endsWith("="))
			url += "=";
		StringBuilder writer = new StringBuilder();
		writer.append("<a href=\"").append(url).append(getValue()).append("\" target=\"").append(getTarget()).append("\"");
		writer.append(">").append(getCaption()).append("</a>");
		return writer.toString();
	}
}
